package com.example.gulimallgetway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
import org.springframework.web.cors.reactive.CorsWebFilter;

@Configuration
public class GuliCrosConfiguration {
    @Bean
    public CorsWebFilter corsWebFilter(){
        UrlBasedCorsConfigurationSource configurationSource = new UrlBasedCorsConfigurationSource();
        CorsConfiguration crosConfiguration = new CorsConfiguration();
        configurationSource.registerCorsConfiguration("/**",crosConfiguration);

        crosConfiguration.addAllowedHeader("*");
        crosConfiguration.addAllowedMethod("*");
        crosConfiguration.addAllowedOriginPattern("*");
        crosConfiguration.setAllowCredentials(true);
        return new CorsWebFilter(configurationSource);
    }
}
